package com.wdzj.hsz.service.impl;

import java.util.List;

import com.wdzj.common.pojo.ZjDraftInfo;
import com.wdzj.common.pojo.ZjPaymentBatch;
import com.wdzj.common.pojo.ZjPaymentInfo;
import com.wdzj.common.pojo.ZjSchoolrollChange;
import com.wdzj.common.pojo.ZjStuInfo;
import com.wdzj.commons.PublicUtil;
import com.wdzj.hsz.dao.iface.HszDao;
import com.wdzj.hsz.service.iface.HszService;

public class HszServiceImpl implements HszService {

	private HszDao hszdao;

	public HszDao getHszdao() {
		return hszdao;
	}

	public void setHszdao(HszDao hszdao) {
		this.hszdao = hszdao;
	}
	public List getInfolei(String sql,Class c){
		return hszdao.getLeisql(sql, c, "");
	}
	public List getInfosql(String sql)
	{
		return hszdao.getinfosql(sql);
	}
	public List getInfo(String hql){
		return hszdao.getinfo(hql);
	}
	
	public void addOb(Object o){
		hszdao.addObject(o);
	}
	
	public void updateOb(Object o){
		hszdao.updateObject(o);
	}
	
	public void exeHql(String  hql){
		hszdao.excutesql(hql);
	}
	
	public void exeSql(String sql) {
		hszdao.excutePuTongsql(sql);
	}
	
	public boolean exeSqlCount(String sql){
		return hszdao.excuteUpdate(sql);
	}
	
	public void cimJf(ZjPaymentBatch batch){
		hszdao.addObject(batch);
		hszdao.excutesql("update ZjStuInfo t set t.groupid=5,t.schoolrollsstate2='x205',t.stuflag='4',t.stupwddate='"+batch.getEndtime()+"' where t.navitas='"+batch.getNavitas()+"' and t.grade='"+batch.getGrade()+"' and t.layering='"+batch.getLevels()+"' and t.stuflag='5'");
	}
	public void cimupJf(ZjPaymentBatch batch){
		hszdao.updateObject(batch);
		hszdao.excutesql("update ZjStuInfo t set t.groupid=5,t.schoolrollsstate2='x205',t.stuflag='4',t.stupwddate='"+batch.getEndtime()+"' where t.navitas='"+batch.getNavitas()+"' and t.grade='"+batch.getGrade()+"' and t.layering='"+batch.getLevels()+"' and t.stuflag='5'");
	}
	public void cimShenhe(String  stuid,String jiaofeiid,String pici){
		hszdao.excutesql("update ZjStuInfo t set t.schoolrollsstate2='x201', t.stuflag='5',t.groupid=6, t.stupwddate='9999-99-99' where t.stuid="+stuid);
		hszdao.excutesql("update ZjPaymentInfo t set t.payFlag='1',t.verifyDate='"+PublicUtil.getNowDate()+"',t.verifyBatch='"+pici+"' where t.jiaofenId="+jiaofeiid);
	}
	public void cimShenhe2(ZjStuInfo s,ZjPaymentBatch b,ZjPaymentInfo i,ZjDraftInfo d){
		i.setStuid(s.getStuid());
		i.setPaymentbatchid(b.getPaymentbatchid());
		i.setJiaofenDate(PublicUtil.getNowDate());
		i.setPayWay("1");
		i.setPayFlag("1");
		i.setPayOther(s.getStuid());
		i.setVerifyDate(PublicUtil.getNowDate());
		hszdao.addObject(i);
		d.setJiaofenId(i.getJiaofenId());
		hszdao.addObject(d);
		
		hszdao.excutesql("update ZjStuInfo t set t.schoolrollsstate2='x201', t.stuflag='5',t.groupid=6, t.stupwddate='9999-99-99' where t.stuid="+s.getStuid());
	}
	public void cimscJf(String id){
		hszdao.excutePuTongsql("delete from ZJ_DRAFT_INFO t where t.jiaofen_id in (select p.jiaofen_id from Zj_Payment_Info p where p.paymentbatchid="+id+")");
		hszdao.excutePuTongsql("delete from Zj_Payment_Info p where p.paymentbatchid="+id);
		hszdao.excutePuTongsql("delete from Zj_Payment_Batch p where p.paymentbatchid="+id);
	}
	public void cimDrxj(String stuid,String xj1,String xj2,ZjSchoolrollChange sc){
		hszdao.excutesql("update ZjStuInfo t set t.schoolrollsstate1='"+xj1+"',t.schoolrollsstate2='"+xj2+"' where t.stuid="+stuid);
		hszdao.addObject(sc);
	}
}
